package com.ry.core.base.dao.hibernate;

import java.io.Serializable;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.ry.core.base.model.SimpleModel;
import com.ry.core.exception.DaoException;

/**
 * hibernate接口类
 * 
 * @author lqw
 * 
 */
public interface HibernateDao {

	/**
	 * 新增一个对象
	 * 
	 * @param object
	 * @return
	 * @throws DataAccessException
	 */
	public abstract void add(SimpleModel entity) throws DaoException;

	/**
	 * 编辑一个对象
	 * 
	 * @param object
	 * @return
	 * @throws DataAccessException
	 */
	public abstract SimpleModel edit(SimpleModel entity) throws DaoException;

	/**
	 * 删除单个对象
	 * 
	 * @param id
	 * @return
	 * @throws DataAccessException
	 */
	public abstract void remove(SimpleModel entity) throws DaoException;

	/**
	 * 获取template
	 * 
	 * @return
	 */
	public HibernateTemplate getTemplate() throws DaoException;

	/**
	 * 根据主键取对象
	 * 
	 * @param theClass
	 * @param pk
	 * @return
	 * @throws DaoException
	 */
	public SimpleModel get(Class<?> theClass, String id)
			throws DaoException;

	/**
	 * 判断当前对象是否存在
	 * 
	 * @param theClass
	 * @param pk
	 * @return
	 */
	public boolean isExist(Class<?> theClass, Serializable pk);

	/**
	 * 获取记录数
	 * 
	 * @param countHQL
	 * @return
	 */
	public int queryCount(final String countHQL);

	SimpleModel editObj(SimpleModel entity) throws DaoException;

}
